package com.jiahui.account;

import org.achartengine.ChartFactory;
import org.achartengine.GraphicalActivity;
import org.achartengine.GraphicalView;
import org.achartengine.model.CategorySeries;
import org.achartengine.renderer.DefaultRenderer;
import org.achartengine.renderer.SimpleSeriesRenderer;

import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class MainActivity extends TabActivity {

	private static final String TAB_HOME = "home";
	private static final String TAB_COUNT = "count";
	private static final String TAB_ACCOUNT = "account";
	private static final String TAB_REPORT = "report";

	private TabHost tabHost;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		tabHost = this.getTabHost();

		TabSpec homeSpec = tabHost.newTabSpec(TAB_HOME).setIndicator(TAB_HOME)
				.setContent(new Intent(this, HomeActivity.class));
		TabSpec atSpec = tabHost.newTabSpec(TAB_COUNT).setIndicator(TAB_COUNT)
				.setContent(new Intent(this, CountActivity.class));
		TabSpec msgSpec = tabHost.newTabSpec(TAB_ACCOUNT)
				.setIndicator(TAB_ACCOUNT)
				.setContent(new Intent(this, AccountActivity.class));
		TabSpec moreSpec = tabHost.newTabSpec(TAB_REPORT)
				.setIndicator(TAB_REPORT)
				.setContent(new Intent(this, ReportActivity.class));

		tabHost.addTab(homeSpec);
		tabHost.addTab(atSpec);
		tabHost.addTab(msgSpec);
		tabHost.addTab(moreSpec);

		tabHost.setCurrentTabByTag(TAB_HOME);

		RadioGroup radioGroup = (RadioGroup) this
				.findViewById(R.id.rg_main_btns);

		radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			public void onCheckedChanged(RadioGroup group, int checkedId) {

				switch (checkedId) {
				case R.id.rd_home:
					tabHost.setCurrentTabByTag(TAB_HOME);
					break;

				case R.id.rd_account:
					tabHost.setCurrentTabByTag(TAB_ACCOUNT);
					break;

				case R.id.rd_count:
					tabHost.setCurrentTabByTag(TAB_COUNT);
					break;

				case R.id.rd_report:
					tabHost.setCurrentTabByTag(TAB_REPORT);
					break;

				default:
					break;
				}

			}
		});

	}

}
